﻿<?php

if(!defined('IN_PHPSCUP'))exit('hacking'); 
class CompanyalonepageApp extends BaseApp
{
    var $type = 'companyalonepage';
	
    function index()
    {

	    $TB_alonepage = &$this->_model('companyalonepage'); 	 
		
		$data = $TB_alonepage->show($GLOBALS['SCup']->SCup_user_msg['user_id']);
        $this->assign('lw_data', $data['data']);		
		$this->assign('lw_page', $data['page']);	
		   		
/*	 	$categorydata = & $GLOBALS['SCup']->_get_category_data($this->type);
		if(!is_array($categorydata))
		{
		 $categorydata = (array)$categorydata;
		}		
		$categorylist = array();
		foreach($categorydata as $value)
		{
		    $categorylist[$value['cat_id']] = $value['cat_name'];
		}		
		
        $this->assign('categorylist', $categorylist);
*/							
	    
		
        $this->assign('view_charset', VIEW_CHARSET);	
        $this->assign('page_title', $GLOBALS['Lang']->_get_lang_var(SITE_TITLE));
        $this->assign('page_description', $GLOBALS['Lang']->_get_lang_var(SITE_DESCRIPTION));
        $this->assign('page_keywords', $GLOBALS['Lang']->_get_lang_var(SITE_KEYWORDS));	
		
        $this->assign('site_url',SITE_URL);
		
        $this->assign('web_view_dir',SITE_URL.'/admin/view/default/');
		
        $this->display('company/companyalonepagelist.view.html');
    }

    function add()
    {	
	    $time = time();
		
		$data = array();
		
		$data['filename'] = $time.'.html' ;
        $this->assign('data', $data);	
    		
		
        $this->assign('view_charset', VIEW_CHARSET);	
        $this->assign('page_title', $GLOBALS['Lang']->_get_lang_var(SITE_TITLE));
        $this->assign('page_description', $GLOBALS['Lang']->_get_lang_var(SITE_DESCRIPTION));
        $this->assign('page_keywords', $GLOBALS['Lang']->_get_lang_var(SITE_KEYWORDS));	
		
        $this->assign('site_url',SITE_URL);
        $this->assign('id','');		
        $this->assign('web_view_dir',SITE_URL.'/admin/view/default/');
		
        $this->display('company/companyalonepageadd.view.html');	

    }
	
	
    function addpost()
    {

	     $data = $_POST['data'];

/*
         if(!isset($data['cat_id'])||empty($data['cat_id']))
		{
		 $notice = &get_message(array('msg'=>"所属栏目不能为空!",'url'=>'','title'=>'Notice'));
		 $notice ->display();		 
		 }	
*/	
         if(!isset($data['name'])||empty($data['name']))
		{
		 $notice = &get_message(array('msg'=>"单独页名称不能为空!",'url'=>'','title'=>'Notice'));
		 $notice ->display();		 
		 }	

		 $data['user_id'] = $GLOBALS['SCup']->SCup_user_msg['user_id'];
		 		 
	     $data['filepath'] = '?app=alonepage&pa='.$data['filename'] ;		 

	 	 $TB_company= &$this->_model('company');		 		 		
		 $companydata = $TB_company->oneshow($GLOBALS['SCup']->SCup_user_msg['user_id']);
         $data['company_id']=$companydata['id'];	
	 
		 $TB_alonepage = &$this->_model('companyalonepage'); 	 
		
		 $TB_alonepage->post($data,$GLOBALS['SCup']->SCup_user_msg['user_id']);
	 
		 $notice = &get_message(array('msg'=>"添加成功!",'url'=>'','title'=>'Notice'));
		 $notice ->display();

    }

    function edit()
    {	
		$id = $_GET['id'];
		 $TB_alonepage = &$this->_model('companyalonepage'); 	 
		
		$data = $TB_alonepage->oneshow($id,$GLOBALS['SCup']->SCup_user_msg['user_id']);


	    $this->assign('data', $data);		
			
	    $this->assign('nav_lang', get_all_dirname(ROOT_PATH . '/languages'));	
	    
        $this->assign('view_charset', VIEW_CHARSET);	
        $this->assign('page_title', $GLOBALS['Lang']->_get_lang_var(SITE_TITLE));
        $this->assign('page_description', $GLOBALS['Lang']->_get_lang_var(SITE_DESCRIPTION));
        $this->assign('page_keywords', $GLOBALS['Lang']->_get_lang_var(SITE_KEYWORDS));	
		
        $this->assign('site_url',SITE_URL);
		
        $this->assign('web_view_dir',SITE_URL.'/admin/view/default/');
		
        $this->display('company/companyalonepageedit.view.html');
    }





    function editpost()
    {

	     $data = $_POST['data'];
		 /*
         if(!isset($data['cat_id'])||empty($data['cat_id']))
		{
		 $notice = &get_message(array('msg'=>"所属栏目不能为空!",'url'=>'','title'=>'Notice'));
		 $notice ->display();		 
		 }	
		 */

         if(!isset($data['name'])||empty($data['name']))
		{
		 $notice = &get_message(array('msg'=>"单独页名称不能为空!",'url'=>'','title'=>'Notice'));
		 $notice ->display();		 
		 }

		 $data['user_id'] = $GLOBALS['SCup']->SCup_user_msg['user_id'];
		 		 
	     $data['filepath'] = '?app=alonepage&pa='.$data['filename'] ;
		 
		 $id = intval($data['id']);	 
		 
	 	 $TB_company= &$this->_model('company');		 		 		
		 $companydata = $TB_company->oneshow($GLOBALS['SCup']->SCup_user_msg['user_id']);
         $data['company_id']=$companydata['id']; 
		 

		 $TB_alonepage = &$this->_model('companyalonepage'); 	 	 
		
		 $TB_alonepage->editaction($id,$data,$GLOBALS['SCup']->SCup_user_msg['user_id']);
		 
		 $notice = &get_message(array('msg'=>"修改成功!",'url'=>'','title'=>'Notice'));
		 $notice ->display();
		 

    }



    function del()
    {

	     $id = $_GET['id'];
		$TB_new = &$this->_model('companyalonepage');
		
		$TB_new->del($id,$GLOBALS['SCup']->SCup_user_msg['user_id']);

		 $notice = &get_message(array('msg'=>"删除成功!",'url'=>'','title'=>'Notice'));
		 $notice ->display();		  

    }



    function kindeditor()
    {
    $w = intval($_GET['w']);
    include(ROOT_PATH."/data/ewebeditor/ewebeditor.lib.php");	
	$kindeditor = new Ewebeditor(array('imageUploadCgi'=>SITE_URL.'/index.php?app='.$this->type.'&act=kindeditorupfile&w='.$w));
	$kindeditor->show();
	
    }
	
    function kindeditorupfile()
    {
    $w = intval($_GET['w']);
    include(ROOT_PATH."/data/ewebeditor/ewebeditor.lib.php");	
	$kindeditor = new Ewebeditor(array('imageUploadCgi'=>SITE_URL.'/index.php?app='.$this->type.'&act=kindeditorupfile&w='.$w));
	$kindeditor->upfile($this->type.'/'.$GLOBALS['SCup']->SCup_user_msg['user_id'].'/'.$w);	
	
    }
	

    function cagryadd()
    {
		$GLOBALS['Lang']->_get_lang('alonepage');	
	    $category = & $GLOBALS['SCup']->_get_category();
		 		 		
		$catgydata = $category->show($this->type);
		
		$catgystr = $category->html_format_category($catgydata,0);	

        $this->assign('catgystr', $catgystr);	
		
        $this->assign('category_value', $this->type);
        $this->assign('appname', $this->type);			    
        $this->assign('view_charset', VIEW_CHARSET);	
        $this->assign('page_title', $GLOBALS['Lang']->_get_lang_var(SITE_TITLE));
        $this->assign('page_description', $GLOBALS['Lang']->_get_lang_var(SITE_DESCRIPTION));
        $this->assign('page_keywords', $GLOBALS['Lang']->_get_lang_var(SITE_KEYWORDS));	
		
        $this->assign('site_url',SITE_URL);
		
        $this->assign('web_view_dir',SITE_URL.'/admin/view/default/');		
		
        $this->display('company/cagryadd.view.html');
    }
	
    function editcatgy()
    {
		$GLOBALS['Lang']->_get_lang('alonepage');
		$id= intval($_GET['id']);
		
	    $category = & $GLOBALS['SCup']->_get_category();
		 		 		
		$catgydata = $category->show($this->type);
		
		$data = $category->oneshow($id);
		
		$catgystr = $category->html_format_category($catgydata,$data['parent_id'],0,0,$id);	
        $this->assign('appname', $this->type);
        $this->assign('data', $data);

        $this->assign('catgystr', $catgystr);
		
        $this->assign('category_value', $this->type);
			    
        $this->assign('view_charset', VIEW_CHARSET);	
        $this->assign('page_title', $GLOBALS['Lang']->_get_lang_var(SITE_TITLE));
        $this->assign('page_description', $GLOBALS['Lang']->_get_lang_var(SITE_DESCRIPTION));
        $this->assign('page_keywords', $GLOBALS['Lang']->_get_lang_var(SITE_KEYWORDS));	
		
        $this->assign('site_url',SITE_URL);
		
        $this->assign('web_view_dir',SITE_URL.'/admin/view/default/');		
		
        $this->display('company/cagryedit.view.html');
    }
	
    function cagrylist()
    {
		$GLOBALS['Lang']->_get_lang('alonepage');		
	    $category = & $GLOBALS['SCup']->_get_category();
		 		 		
		$catgydata = $category->show($this->type);
		$catgydata = $category->get_list_category($catgydata);

        $this->assign('appname', $this->type);		
        $this->assign('catgydata', $catgydata);				
        $this->assign('category_value', $this->type);
	    
        $this->assign('view_charset', VIEW_CHARSET);	
        $this->assign('page_title', $GLOBALS['Lang']->_get_lang_var(SITE_TITLE));
        $this->assign('page_description', $GLOBALS['Lang']->_get_lang_var(SITE_DESCRIPTION));
        $this->assign('page_keywords', $GLOBALS['Lang']->_get_lang_var(SITE_KEYWORDS));	
		
        $this->assign('site_url',SITE_URL);
		
        $this->assign('web_view_dir',SITE_URL.'/admin/view/default/');		
		
        $this->display('company/cagrylist.view.html');
    }

    function cyaddpost()
    {

	     $data = $_POST['data'];
         
		 $category = & $GLOBALS['SCup']->_get_category();
		 		 		
		 $category->post($data);
		 
		 $category->write_cache($this->type);	
		 	 		 
		 $this->cagrylist();

    }


    function cyeditpost()
    {

	     $id = $_POST['id'];

	     $data = $_POST['data'];
         
		 $category = & $GLOBALS['SCup']->_get_category();
		 		 		
		 $category->editaction($id,$data);

		 $category->write_cache($this->type);	
		 	 		 
		 $this->cagrylist();

    }

    function delcatgy()
    {
		$id= intval($_GET['id']);		

	    $category = & $GLOBALS['SCup']->_get_category();		 		 		
		$category->del($id);
		
		$category->write_cache($this->type);
				      
		$this->cagrylist();   
    }	
		



  
}

?>